﻿using DDDEF.Application;
using DDDEF.Domain.Services;
using DDDEF.Infrastructure.Domain.Musics;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Results;

namespace DDDEF.Presentation.Controllers
{
    public class ValuesController : ApiController
    {
        #region Fields

        private IMusicAppService _musicAppService;
        private IMusicService _musicService;


        #endregion
        public ValuesController(IMusicAppService musicAppService,
            IMusicService musicService)
        {
            this._musicAppService = musicAppService;
            this._musicService = musicService;
        }
        // GET api/values
        public JsonResult<List<Music>> Get()
        {
            var musics = _musicAppService.GetAll();

            return Json(musics);
        }

        public RedirectResult ClearCache()
        {
            var music = new Music { };
            _musicService.Insert(music);

            return Redirect("get");
        }

        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}
